
import mirny
from mirny.plugins.input import Input

class Oracle(Input):
	name = _("Oracle Database")
	description = _("Sample plugin to get data from an Oracle Database")
	params = {	"ip": (_("IP Address of the Oracle Listener"), str, True),
			"port": (_("Port of the Oracle Listener"), int, True),
			"sid": ("SID", str, True),
			"user": (_("Username"), str, True),
			"pwd": (_("Password"), str, True),
			"tablespace": (_("Tablespace to focus on"), str, False),
			"table": (_("Table to focus on"), str, False), }
	config = { } # TODO
	
	def init_plugin(self):
		# self.db = connect_to_database avec self.config[' {ip,port,sid...} ']
		# self.tables = get list of tables
		# self.tbl = self.tables.pop()

	def next(self):
		try:
			self.fetch = self.db.execute('select * from '+self.tbl)
			self.tbl = self.tables.pop()
			return True
		except IndexError: # levé par .pop()
			return False

	def get_source(self):
		return self.fetch.makefile() # dans l'idée

